import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

class MyThreadPool {
    private Thread[] arr;
    private BlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(100);

    public MyThreadPool(int capacity) {
        arr = new Thread[capacity];
        for (int i = 0; i < capacity; i++) {
            Thread t = new Thread(() -> {
                try {
                    Runnable task = queue.take();
                    task.run();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            });
            t.start();
        }
    }

    public void submit(Runnable task) throws InterruptedException {
        queue.put(task);
    }
}

public class Demo1 {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 10000; i++) {
            int id = i;
            executorService.submit(() -> {
                System.out.println("hello" + id);
            });
        }
    }
}
